﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ariregistri_toimik_hoiatus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(AriregistriToimikHoiatus))]
    public class AriregistriToimikHoiatusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAriregistriToimikHoiatus clazz;
        
        public AriregistriToimikHoiatusSerializer(IAriregistriToimikHoiatus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("hoiatuse_number");
            if (clazz.HoiatuseNumber!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HoiatuseNumber))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : HoiatuseNumber");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("hoiatuse_kpv");
            if (clazz.HoiatuseKpv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.HoiatuseKpv))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("hoiatuse_liik");
            if (clazz.HoiatuseLiik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HoiatuseLiik))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("hoiatuse_liik_tekstina");
            if (clazz.HoiatuseLiikTekstina!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HoiatuseLiikTekstina))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("hoiatuse_olek");
            if (clazz.HoiatuseOlek!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HoiatuseOlek))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("hoiatuse_olek_tekstina");
            if (clazz.HoiatuseOlekTekstina!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HoiatuseOlekTekstina))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("tahtaeg");
            if (clazz.Tahtaeg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Tahtaeg))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("menetleja_id");
            if (clazz.MenetlejaId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.MenetlejaId))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("menetleja_nimi");
            if (clazz.MenetlejaNimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MenetlejaNimi))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("hoiatuse_tekst");
            if (clazz.HoiatuseTekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HoiatuseTekst))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="hoiatuse_number") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ariregistri_toimik_hoiatus>hoiatuse_number");
                }
                clazz.HoiatuseNumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hoiatuse_number")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>hoiatuse_number", Reader.LocalName);
            }
            if (Reader.LocalName=="hoiatuse_kpv") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.HoiatuseKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("hoiatuse_kpv")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>hoiatuse_kpv", Reader.LocalName);
            }
            if (Reader.LocalName=="hoiatuse_liik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.HoiatuseLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hoiatuse_liik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>hoiatuse_liik", Reader.LocalName);
            }
            if (Reader.LocalName=="hoiatuse_liik_tekstina") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.HoiatuseLiikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hoiatuse_liik_tekstina")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>hoiatuse_liik_tekstina", Reader.LocalName);
            }
            if (Reader.LocalName=="hoiatuse_olek") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.HoiatuseOlek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hoiatuse_olek")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>hoiatuse_olek", Reader.LocalName);
            }
            if (Reader.LocalName=="hoiatuse_olek_tekstina") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.HoiatuseOlekTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hoiatuse_olek_tekstina")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>hoiatuse_olek_tekstina", Reader.LocalName);
            }
            if (Reader.LocalName=="tahtaeg") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Tahtaeg = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("tahtaeg")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>tahtaeg", Reader.LocalName);
            }
            if (Reader.LocalName=="menetleja_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MenetlejaId = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("menetleja_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>menetleja_id", Reader.LocalName);
            }
            if (Reader.LocalName=="menetleja_nimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MenetlejaNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("menetleja_nimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>menetleja_nimi", Reader.LocalName);
            }
            if (Reader.LocalName=="hoiatuse_tekst") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.HoiatuseTekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hoiatuse_tekst")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ariregistri_toimik_hoiatus>hoiatuse_tekst", Reader.LocalName);
            }
        }
    }
}
